/*
 * @Author: tcosfish
 * @Date: 2022-07-27 16:26:28
 * @LastEditors: tcosfish
 * @LastEditTime: 2022-08-17 10:57:08
 * @FilePath: \loadFile\src\excel\utils\tableTemplate.util.ts
 */

import { TableProperties, TableColumnProperties } from "exceljs"

export function tableTemplate(
  name: string,
  start_line: string,
  fields: TableColumnProperties[],
  data: any[]
): TableProperties {
  return {
    name: name,
    displayName: name,
    headerRow: true,
    totalsRow: true,
    ref: start_line,
    style: {
      theme: "TableStyleMedium1",
      showRowStripes: true,
      showFirstColumn: true,
      showLastColumn: true,
    },
    rows: Object.values(data),
    columns: fields,
  }
}
